﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		IUserRepository.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            IUserRepository.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion

using System;
using System.Net.Mail;
using Dexter.Domain.Model;
using Dexter.Domain.Results;

namespace Dexter.Repository {

	/// <summary>
	/// 	Rapresents a repository of <see cref="User"/>.
	/// </summary>
	public interface IUserRepository : IRepository <User> {
		/// <summary>
		/// Saves the specified user into the repository.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <exception cref="ArgumentNullException"> If <paramref name="item"/> is <c>null</c>.</exception>
		void Save ( User item );

		/// <summary>
		/// Updates the specified user into the repository.
		/// </summary>
		/// <param name="item">The item.</param>
		///<exception cref="ArgumentNullException"> If <paramref name="item"/> is <c>null</c>.</exception>
		void Update ( User item );

		/// <summary>
		/// Deletes the specified user into the repository.
		/// </summary>
		/// <param name="item">The item.</param>
		///<exception cref="ArgumentNullException"> If <paramref name="item"/> is <c>null</c>.</exception>
		void Delete ( User item );

		/// <summary>
		/// Gets a user with roles fetched by his key.
		/// </summary>
		/// <param name="key">The key.</param>
		///<exception cref="ArgumentNullException"> If <paramref name="key"/> is lesser than 1.</exception>
		User GetByKeyWithRoles ( int key );

		/// <summary>
		/// Gets a user with roles fetched by his key.
		/// </summary>
		/// <param name="key">The key of hte user.</param>
		/// <param name="enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		///<exception cref="ArgumentNullException"> If <paramref name="key"/> is lesser than 1.</exception>
		User GetByKeyWithRoles ( int key , bool enableTracking );

		/// <summary>
		/// Gets a user with roles fetched by his email.
		/// </summary>
		/// <param name="email">The email of the user.</param>
		/// <returns>An instane of <see cref="User"/> or null if the user will not exist.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="email"/> is <c>null</c>.</exception>
		User GetByEmailWithRoles(MailAddress email);

		/// <summary>
		/// Gets a user with roles fetched by his email.
		/// </summary>
		/// <param name="email">The email of the user.</param>
		/// <param name="enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		/// <returns>An instane of <see cref="User"/> or null if the user will not exist.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="email"/> is <c>null</c>.</exception>
		User GetByEmailWithRoles(MailAddress email, bool enableTracking);

		/// <summary>
		/// Gets a user with roles fetched by his username.
		/// </summary>
		/// <param name="username">The username of the user.</param>
		/// <returns>An instane of <see cref="User"/> or null if the user will not exist.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="username"/> is <c>null</c> or <c>empty</c>.</exception>
		User GetByUsernameWithRoles ( string username );

		/// <summary>
		/// Gets a user with roles fetched by his username.
		/// </summary>
		/// <param name="username">The username of the user.</param>
		/// <param name="enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		/// <returns>An instane of <see cref="User"/> or null if the user will not exist.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="username"/> is <c>null</c> or <c>empty</c>.</exception>
		User GetByUsernameWithRoles ( string username , bool enableTracking );
		
		/// <summary>
		/// Retrieve a list of users with all roles fetched.
		/// </summary>
		/// <param name="pageIndex">Index of the page.</param>
		/// <param name="pageSize">Size of the page.</param>
		///<returns>An concrete implementation of <see cref="IPagedResult{T}"/>. The result will never be null.</returns>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageIndex"/> is lesser than 0.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageSize"/> is lesser than 1.</exception>
		IPagedResult <User> GetListOfUserWithRoles ( int pageIndex , int pageSize );

		/// <summary>
		/// Retrieve a list of users with all roles fetched.
		/// </summary>
		/// <param name="pageIndex">Index of the page.</param>
		/// <param name="pageSize">Size of the page.</param>
		/// <param name="enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		///<returns>An concrete implementation of <see cref="IPagedResult{T}"/>. The result will never be null.</returns>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageIndex"/> is lesser than 0.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageSize"/> is lesser than 1.</exception>
		IPagedResult <User> GetListOfUserWithRoles ( int pageIndex , int pageSize , bool enableTracking );

		/// <summary>
		/// Retrieve a list of users with all roles fetched where the username match (%usernameToMatch%) with the passed value.
		/// </summary>
		///<param name="usernameToMatch">The part of the username.</param>
		///<param name="pageIndex">Index of the page.</param>
		/// <param name="pageSize">Size of the page.</param>
		///<returns>An concrete implementation of <see cref="IPagedResult{T}"/>. The result will never be null.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="usernameToMatch"/> is <c>null</c> or <c>empty</c>.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageIndex"/> is lesser than 0.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageSize"/> is lesser than 1.</exception>
		IPagedResult <User> FindUsersByNameWithRoles ( string usernameToMatch , int pageIndex , int pageSize );
		
		/// <summary>
		/// Retrieve a list of users with all roles fetched where the username match (%usernameToMatch%) with the passed value.
		/// </summary>
		///<param name="usernameToMatch">The part of the username.</param>
		///<param name="pageIndex">Index of the page.</param>
		/// <param name="pageSize">Size of the page.</param>
		/// <param name="enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		///<returns>An concrete implementation of <see cref="IPagedResult{T}"/>. The result will never be null.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="usernameToMatch"/> is <c>null</c> or <c>empty</c>.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageIndex"/> is lesser than 0.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageSize"/> is lesser than 1.</exception>
		IPagedResult <User> FindUsersByNameWithRoles ( string usernameToMatch , int pageIndex , int pageSize , bool enableTracking );

		/// <summary>
		/// Retrieve a list of users with all roles fetched where the email match (%emailToMatch%) with the passed value.
		/// </summary>
		///<param name="emailToMatch">The part of the email.</param>
		///<param name="pageIndex">Index of the page.</param>
		/// <param name="pageSize">Size of the page.</param>
		///<returns>An concrete implementation of <see cref="IPagedResult{T}"/>. The result will never be null.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="emailToMatch"/> is <c>null</c> or <c>empty</c>.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageIndex"/> is lesser than 0.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageSize"/> is lesser than 1.</exception>
		IPagedResult <User> FindUsersByEmailWithRoles ( string emailToMatch , int pageIndex , int pageSize );

		/// <summary>
		/// Retrieve a list of users with all roles fetched where the email match (%emailToMatch%) with the passed value.
		/// </summary>
		///<param name="emailToMatch">The part of the email.</param>
		///<param name="pageIndex">Index of the page.</param>
		/// <param name="pageSize">Size of the page.</param>
		/// <param name="enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		///<returns>An concrete implementation of <see cref="IPagedResult{T}"/>. The result will never be null.</returns>
		///<exception cref="ArgumentNullException"> If <paramref name="emailToMatch"/> is <c>null</c> or <c>empty</c>.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageIndex"/> is lesser than 0.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageSize"/> is lesser than 1.</exception>
		IPagedResult <User> FindUsersByEmailWithRoles ( string emailToMatch , int pageIndex , int pageSize , bool enableTracking );

		/// <summary>
		/// Return the number of users online in the specified window time.
		/// </summary>
		/// <param name="userIsOnlineTimeWindow">The user is online time window.</param>
		/// <exception cref="ArgumentOutOfRangeException">Will be throw if the 'userIsOnlineTimeWindow' will be lesser than 1.</exception>
		/// <returns>The numbers of users online.</returns>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="userIsOnlineTimeWindow"/> is lesser than 1.</exception>
		int GetOnlineUsers ( int userIsOnlineTimeWindow );

		/// <summary>
		/// Retrieve a list all roles.
		/// </summary>
		///<param name="pageIndex">Index of the page.</param>
		/// <param name="pageSize">Size of the page.</param>
		/// <param name="enableTracking">if set to <c>true</c> the tracking system of the return object will be enable.</param>
		///<returns>An concrete implementation of <see cref="IPagedResult{T}"/>. The result will never be null.</returns>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageIndex"/> is lesser than 0.</exception>
		///<exception cref="ArgumentOutOfRangeException"> If <paramref name="pageSize"/> is lesser than 1.</exception>
		IPagedResult<Role> GetAllRoles ( int pageIndex, int pageSize, bool enableTracking );
	}
}
